/*
 * Boom.fx
 *
 * Created on 27.10.2009, 1:50:47
 */

package justforfun.bombsquare;

import javafx.scene.Node;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import justforfun.bombsquare.Constants.*;
import justforfun.bombsquare.myNode;

/**
 * @author civil
 */

public class BoomSquare extends myNode {
    public var fill: Color = Color.RED;
    public var stroke: Color = Color.WHITE;
    public var action: function(): Void = null;
    public var waitTime: Duration = 1s;
    var height: Float = my;
    var width: Float = mx;

    var oldX = x;
    var oldY = y;

    var waiting = Timeline {
        keyFrames: [
                KeyFrame {

                    time: waitTime
                    values: [
                            height => my / 2,
                            width => mx / 2
                    ]
                },
                KeyFrame {
                    time: waitTime
                    action: action
                }
        ]
    }

    override public function create(): Node {
        var rec = Rectangle {
            x: x * mx
            y: y * my
            height: bind height
            width: bind width
            stroke: stroke
            fill: fill
        }
        waiting.playFromStart();
        return rec
    }

}